﻿using System.Linq;
using MRGSP.SurveyMaster.Core;
using MRGSP.SurveyMaster.Core.Model;
using MRGSP.SurveyMaster.Core.Service.Utils;

namespace MRGSP.SurveyMaster.Service.Utils
{
    public class GridCellCreateBuilder : IQuestionBuilder
    {
        public string Build(Question q)
        {
            var result = string.Empty;

            return string.Format("<td><div id='qwrap{1}'>{0}</div></td>",
               q.Children.Aggregate(result, (current, child)
                => current + QuestionCreateBuilder.Get(ControlType.GridCellList).Build(child)),
                q.Id);
        }
    }
}